home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 3.5 KB | 145 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
- //
- // Restricted Rights Legend
- // Use, duplication, or disclosure is subject to restrictions as set forth
- // in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer
- // Software clause at DFARS 252.227-7013.
- //
- // BCExcept.cpp
- //
- // This file contains the definitions for the classes and functions
- // associated with exception handling.
-
- #include <stdlib.h>
- #include <string.h>
- #include "BCExcept.h"
-
- #ifdef BC_CAN_EXPORT_DATA
- const char* BC_SHARED_DATA BC_kDisjoint = "objects are members of different structures";
- const char* BC_SHARED_DATA BC_kDuplicate = "object already exists";
- const char* BC_SHARED_DATA BC_kEmpty = "object is empty";
- const char* BC_SHARED_DATA BC_kFull = "object is full";
- const char* BC_SHARED_DATA BC_kIllegal = "illegal pattern";
- const char* BC_SHARED_DATA BC_kInvalidIndex = "index is out of range";
- const char* BC_SHARED_DATA BC_kInvalidNumber = "string does not denote a valid number";
- const char* BC_SHARED_DATA BC_kMissing = "object does not exist";
- const char* BC_SHARED_DATA BC_kNull = "object is null";
- const char* BC_SHARED_DATA BC_kNotEmpty = "object is not empty";
- const char* BC_SHARED_DATA BC_kNotRoot = "object is not at root of structure";
- const char* BC_SHARED_DATA BC_kOutOfMemory = "free storage exhausted";
- const char* BC_SHARED_DATA BC_kReferenced = "object is referenced and cannot be destroyed";
- const char* BC_SHARED_DATA BC_kTooLarge = "object is too large";
- const char* BC_SHARED_DATA BC_kTooSmall = "object is too small";
- #else
- const char* BC_Get_kDisjoint()
- {
- return "objects are members of different structures";
- }
-
- const char* BC_Get_kDuplicate()
- {
- return "object already exists";
- }
-
- const char* BC_Get_kEmpty()
- {
- return "object is empty";
- }
-
- const char* BC_Get_kFull()
- {
- return "object is full";
- }
-
- const char* BC_Get_kIllegal()
- {
- return "illegal pattern";
- }
-
- const char* BC_Get_kInvalidIndex()
- {
- return "index is out of range";
- }
-
- const char* BC_Get_kInvalidNumber()
- {
- return "string does not denote a valid number";
- }
-
- const char* BC_Get_kMissing()
- {
- return "object does not exist";
- }
-
- const char* BC_Get_kNotEmpty()
- {
- return "object is not empty";
- }
-
- const char* BC_Get_kNotRoot()
- {
- return "object is not at root of structure";
- }
-
- const char* BC_Get_kNull()
- {
- return "object is null";
- }
-
- const char* BC_Get_kOutOfMemory()
- {
- return "object is null";
- }
-
- const char* BC_Get_kReferenced()
- {
- return "object is referenced and cannot be destroyed";
- }
-
- const char* BC_Get_kTooLarge()
- {
- return "object is too large";
- }
-
- const char* BC_Get_kTooSmall()
- {
- return "object is too small";
- }
-
- #endif
-
- BC_XException::BC_XException(const char* name, const char* who, const char* what)
- {
- fName[0] = fWho[0] = fWhat[0] = '\0';
- #ifdef BC_DEBUG
- if (name)
- strncpy(fName, name, BC_MAXIMUM_LENGTH);
- if (who)
- strncpy(fWho, who , BC_MAXIMUM_LENGTH);
- if (what)
- strncpy(fWhat, what, BC_MAXIMUM_LENGTH);
- fName[BC_MAXIMUM_LENGTH] = fWho [BC_MAXIMUM_LENGTH] = fWhat[BC_MAXIMUM_LENGTH] = '\0';
- #endif
- }
-
- void BC_XException::Display() const
- {
- #ifdef FW_DEBUG
- FW_CDebugConsole* debugConsole = FW_CDebugConsole::GetConsole();
- FW_CDebugStream& debugStream = debugConsole->GetFatalErrorStream();
- debugStream << fName << " (who: " << fWho << ", what: " << fWhat << ")";
- #endif
- }
-
- void BC_Catch(const BC_XException& e)
- {
- #ifdef FW_DEBUG
- FW_CDebugConsole* debugConsole = FW_CDebugConsole::GetConsole();
- FW_CDebugStream& debugStream = debugConsole->GetFatalErrorStream();
- debugStream << "EXCEPTION: ";
- #endif
- e.Display();
- exit(1);
- }
-